# Setup AD login for the VM
# The main purpose here is to register the IP to the DNS to allow host name access
# http://community.spiceworks.com/how_to/44885-setup-centos-to-authenticate-via-active-directory
#
# Vagrant bridged network is required at eth1 for this to work. Else it will just bind to the
# NAT IP which will not work at all.
# Not used anymore. But keep as a reference if needed in future

Install required packages:
  pkg.installed:
    - pkgs:
      - authconfig
      - krb5-workstation
      - pam_krb5
      - samba
      - samba-common
      - oddjob-mkhomedir
      - sudo
      - ntp

Run authconfig to setup initial auth configuration:
  cmd.script:
    - name: run-authconfig
    - source: salt://join-ad/run-authconfig.sh
    
Add interface option specifically for vagrant:
  file.replace:
    - name: /etc/samba/smb.conf
    - pattern: ';\sinterfaces[^\n]+\n'
    - repl: '\tinterfaces = lo eth1\n'

    
Enable messagebus service:
    service.running:
      - name: messagebus
      - enable: true

Enable oddjobd service:
    service.running:
      - name: oddjobd
      - enable: true
      
Enable windbind service:
    service.running:
      - name: winbind
      - enable: true
      
Run the actual join domain command:
  cmd.script:
    - name: join-domain
    - source: salt://join-ad/join-domain.sh
